import axios from 'axios'

let state = {
    productList:[]
}

let mutations = {
    changeList(state,arr){
        state.productList = arr;
    }
}

let actions = {
    getProduct({commit}){
        axios.get('/api/product').then(res => {
            if(res.data.code === 1){
                console.log(res.data.data);
                commit('changeList',res.data.data); 
            }
        })
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
